//
//  MyNavigationViewController.m
//  PeopleStreet
//
//  Created by 刘建峰 on 2016/11/29.
//  Copyright © 2016年 yuf. All rights reserved.
//

#import "MyNavigationViewController.h"

@interface MyNavigationViewController ()

@end

@implementation MyNavigationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}


- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    //1. 取出分栏
    UITabBar *tabBar = self.tabBarController.tabBar;
    
    // 将frame左移分栏的宽度
//    CGRect frame = tabBar.frame;
//    frame.origin.x -= tabBar.frame.size.width;
    
    // 动画影藏tabBar
//    [UIView animateWithDuration:0.28 animations:^{
//        tabBar.frame = frame;
//    }];
    tabBar.hidden = YES;
    [super pushViewController:viewController animated:animated];
}

- (UIViewController *)popViewControllerAnimated:(BOOL)animated
{
    //1. 取出分栏
    UITabBar *tabBar = self.tabBarController.tabBar;
    
    // 将frame左移分栏的宽度
//    CGRect frame = tabBar.frame;
//    frame.origin.x += tabBar.frame.size.width;
    
    // 动画影藏tabBar
//    [UIView animateWithDuration:0.28 animations:^{
//        tabBar.frame = frame;
//    }];
    if (self.childViewControllers.count==2) {
        tabBar.hidden = NO;
    }
    return [super popViewControllerAnimated:YES];
}


- (void)popViewController
{
    CATransition* transition = [CATransition animation];
    transition.duration = 0.5;
    transition.type = kCATransitionReveal;
    transition.subtype = kCATransitionFromBottom;
//    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
    [self.view.layer addAnimation:transition forKey:kCATransition];
    [self popViewControllerAnimated:NO];

    
}


- (void)pushToViewController:(UIViewController *)viewController
{
    CATransition* transition = [CATransition animation];
    transition.duration = 0.3;
    transition.type = kCATransitionMoveIn;
    transition.subtype = kCATransitionFromTop;
//    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
    
    [self.view.layer addAnimation:transition forKey:kCATransition];
    [self pushViewController:viewController animated:NO];
}

//设置是否允许自动旋转
- (BOOL)shouldAutorotate {
    return YES;
}

//设置支持的屏幕旋转方向
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return self.interfaceOrientationMask;
}

//设置presentation方式展示的屏幕方向
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return self.interfaceOrientation;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
